<%--
  Created by IntelliJ IDEA.
  User: Damon
  Date: 2018/4/19
  Time: 15:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="layui/jquery-1.9.1.js"></script>
    <script src="layui/layui.js"></script>
    <link rel="stylesheet" href="layui/css/layui.css">
</head>
<style>
    cite{
        color: white;
    }
</style>

<body>

     <input id="ccc" type="hidden" value=<%=request.getParameter("userid")%>>


<div class="layui-layout layui-layout-admin">
    <div class="layui-header">

        <div class="layui-logo">layui 后台布局</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">

            <li class="layui-nav-item">
                <a href="javascript:;">个人中心</a>
                <dl class="layui-nav-child">
                    <dd><a href="javascript:userinfo()">用户基本信息</a></dd>
                    <dd><a href="">平台余额</a></dd>
                    <dd><a href="">添加银行卡</a></dd>
                </dl>
            </li>
        </ul>




        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="/personlogin.jsp">
                    <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
                     <div id="ddd" style="margin-left: 5px;display: inline-block">
                       <%=request.getParameter("username")%>
                     </div>
                </a>
            </li>
            <li class="layui-nav-item"><a href="">退朝</a></li>
        </ul>
    </div>


<%--

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">

            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->


            <ul id="nav" style="  cursor: pointer;color:white">


            </ul>





        </div>



    </div>--%>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;" id="index_loaddiv">


            <table style="color:white;" class="layui-hide" id="stest"></table>

            <div id="laypage">



            </div>


            <div style="width: 200px;height: 150px;display: none"  id="divs" >


            </div>



        </div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © layui.com - 底部固定区域


    </div>
</div>

<script>

    function userinfo() {

       location.href="http://localhost:8080/userlist.jsp"
    }


</script>
<script>
    //JavaScript代码区域
    layui.use('element', function(){
        var element = layui.element;
    });
</script>
<script>

    layui.use('laypage', function(){
        var laypage = layui.laypage;
        //执行一个laypage实例
        laypage.render({
            //每页显示几条
            limit:5,
// 			  theme:"red",
            //
            groups:5,
// 			  prev:"←",
// 			  next:"→",
            elem: 'laypage',
            count:10, //数据总数，从服务端得到
            jump: function(obj, first){

                //当前页
                tableinit(obj.curr,obj.limit)
            }
        });
    });


    function  tableinit(curr,limit) {

        layui.use('table', function(){
            var table = layui.table;
            table.render({
                elem: '#stest'
                ,id: "table"
                ,url:'http://localhost:8088/user/getShopCarList'
                ,cellMinWidth: 200 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
                ,cols: [[
                    {field:'shopid', width:"10%", title: 'ID', sort: true},
                    {field:'shopname', width:"20%", title: '标题', sort: true},
                    {field:'shopcount', width:"10%", title: '路径', sort: true},
                    {field:'shopprice', width:"10%", title: '操作', sort: true},
                    {field:'wy', width:"10%", title: '操作', sort: true}
                ]],
                where:{
                    curr:curr,
                    limit:limit,
                }
            });
        });
    }
    function shopPingCar(shopid){


        username=$("#ddd").val().replace(/(^\s*)|(\s*$)/g, "");
        userid= $("#ccc").val().replace(/(^\s*)|(\s*$)/g, "");



        $.ajax({
            url:"http://localhost:8088/user/ShoppingCar",
            data:{shopid:shopid,shopcount:1,username:$("#ddd").html(),userid:$("#ccc").val()},
            dataType:"text",
            async:false,
            type:"GET",
            success:function(result){
                result =     eval("("+result+")")

                location.href="http://localhost:8080/show.jsp?id="+result.id

            }

        })



    }

    function details(shopid){

        $.ajax({
            url:"http://localhost:8088/user/quercommodityByid",
            data:{shopid:shopid},
            dataType:"text",
            async:false,
            type:"GET",
            success:function(result){

                $("#divs").html(result)
            }
        })


        layer.open({
            move:false,   //允许拖拽
            fixed:true,
            resize:false,   //禁止改变大小
            type: 1//此处以iframe举例
            ,title: '商品用户详情'
            ,area: ['auto', 'auto']
            ,shade: 0
            ,maxmin: false
            ,offset: [
                "50%","50%"
            ]
            ,content: $("#divs").html()
            ,btn: ['不错吧', '快去买吧！！！'] //只是为了演示
            ,yes: function(){

            }
            ,btn2: function(){
                // layer.closeAll();
            }

        });


    }

    function shopping(shopid){


        alert("购买成功")

    }




</script>


</body>
</html>
